package top.wshape1.shiziapi.uaa.controller;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import top.wshape1.shiziapi.common.domain.to.UserTokenTo;
import top.wshape1.shiziapi.common.utils.R;
import top.wshape1.shiziapi.uaa.service.JwtService;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2023-08-24
 */

@RestController
@RequestMapping("/token")
public class JwtController {

    @Resource
    private JwtService jwtService;

    @PostMapping("/renew")
    public R<UserTokenTo> renewJwt(@RequestParam Long id, @RequestBody String oldToken) {

        UserTokenTo userTokenTo = jwtService.renewJwt(id, oldToken);

        return R.ok().putData(userTokenTo);
    }

}
